<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

// 基础路由
Route::get('basic1', function () {
    return 'Hello Basic1';
});

Route::post('basic2', function () {
    return 'Hello Basic2';
});

// 多请求路由
Route::match(['get', 'post'], 'basic3', function () {
    return 'Hello Match Basic3';
});

Route::any('basic4', function () {
    return 'Hello Any Basic4';
});

// 路由参数
Route::get('/user/{id}', function ($id) {
    return 'Hello user-id-' . $id;
});

Route::get('/user/{name?}', function ($name = 'bill') {
    return 'Hello user-name-' . $name;
});

Route::get('/user/{id}/{name?}', function ($id, $name = 'bill') {
    return 'Hello user-id-' . $id . '-name-' . $name;
})->where(['id' => '[0-9]+', 'name' => '[A-Za-z]+']);

// 路由别名
Route::get('/member/center', ['as' => 'center', function () {
    return route('center');
}]);

// 路由数组
Route::group(['prefix' => 'center'], function () {
    Route::get('/member/center', ['as' => 'center', function () {
        return 'group1-center';
    }]);
    Route::get('/user/{id}', function ($id) {
        return 'group2 user-id-' . $id;
    });
});

//Route::get('/member/info', 'MemberController@info');

//Route::get('/member/info', ['uses' => 'MemberController@info']);

//Route::get('/member/info', ['uses' => 'MemberController@info', 'as' => 'memberinfo']);

Route::get('/member/{id}', ['uses' => 'MemberController@info'])->where(['id' => '[0-9]+']);

Route::get('test1', ['uses' => 'StudentController@test1']);
Route::get('test2', ['uses' => 'StudentController@test2']);
Route::get('test3', ['uses' => 'StudentController@test3']);
Route::get('test4', ['uses' => 'StudentController@test4']);
Route::get('test5', ['uses' => 'StudentController@test5']);
Route::get('orm1', ['uses' => 'StudentController@orm1']);
Route::get('orm2', ['uses' => 'StudentController@orm2']);
Route::get('orm3', ['uses' => 'StudentController@orm3']);
Route::get('orm4', ['uses' => 'StudentController@orm4']);
Route::get('section1', ['uses' => 'StudentController@section1']);
Route::get('url', ['as' => 'url', 'uses' => 'StudentController@urlTest']);
Route::get('request1', ['uses' => 'StudentController@request1']);

Route::get('activity0', ['uses' => 'StudentController@activity0']);
Route::group(['middleware' => 'activity'], function () {
    Route::get('activity1', ['uses' => 'StudentController@activity1']);
    Route::get('activity2', ['uses' => 'StudentController@activity2']);
});


Route::group(['middleware' => ['web']], function () {
    Route::any('session1', ['uses' => 'StudentController@session1']);
    Route::any('session2', ['as' => 'session21',
        'uses' => 'StudentController@session2']);
    Route::any('student/index', ['uses' => 'StudentController@index']);
    Route::any('student/create', ['uses' => 'StudentController@create']);
    Route::any('student/save', ['uses' => 'StudentController@save']);
    Route::any('student/update/{id}', ['uses' => 'StudentController@update']);
    Route::any('student/detail/{id}', ['uses' => 'StudentController@detail']);
    Route::any('student/delete/{id}', ['uses' => 'StudentController@delete']);
});
Route::get('response', ['uses' => 'StudentController@response']);


// 路由视图
Route::get('/login', function () {
    return view('welcome');
});